package com.alibaba.citrus.cr.common.enums.ordercenter;

import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

@Getter
public enum StockUnitEnum {
    PC("PC", "件"),
    ZHA("ZHA", "张"),
    KG("KG", "千克"),
    EA("EA", "个"),
    M3("M3", "立方米"),
    KB("KB", "千包"),
    KUA("KUA", "块"),
    HE("HE", "盒"),
    ZU("ZU", "组"),
    BOT("BOT", "瓶"),
    KAN("KAN", "听"),
    BAG("BAG", "袋"),
    TNG("TNG", "通"),
    BEI("BEI", "杯"),
    GUA("GUA", "罐"),
    TO("TO", "吨"),
    PAC("PAC", "包"),
    KAR("KAR", "纸板箱"),
    ;

    private String code;
    private String desc;

    StockUnitEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static StockUnitEnum of(String code) {
        return Arrays.stream(StockUnitEnum.values()).filter(source -> Objects.equals(code, source.getCode())).findFirst().orElse(null);
    }
}
